package com.ruoyi.safe.task;

import com.ruoyi.quality.mapper.TQualityFileMapper;
import com.ruoyi.safe.constant.SafeJobConstants;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Auther: lxg
 * @Date: 2024年3月5日09:12:29
 * @Description: 更新质量文件表 逾期状态
 * @Version: 1.0
 */
@Component
@Slf4j
@AllArgsConstructor
public class UpdateTableTaskJob {

    private final TQualityFileMapper tQualityFileMapper;

    @XxlJob(value = SafeJobConstants.JOB_UPDATE_TABLE)
    public ReturnT<String> executeJob() {
        try {
            /*更新质量文件过期状态*/
            int m =tQualityFileMapper.updateOverDueStatus();
            /*更新质量问题过期状态*/
            int n = tQualityFileMapper.updateQuestionOverDueStatus();
            log.info("更新质量文件逾期状态完成！完成质量文件更新"+m+"条，更新质量问题更新"+n+"条");
        } catch (Exception e) {
            log.error("===== 调度发生的的异常为：{}", e.getMessage());
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
